package com.brillilab.service.core.user.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.brillilab.dao.mapper.user.UserExpireJobMapper;
import com.brillilab.domain.po.user.UserExpireJob;
import com.brillilab.service.core.user.IUserExpireJobService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zlb
 * @since 2019-10-14
 */
@Service
public class UserExpireJobServiceImpl extends ServiceImpl<UserExpireJobMapper, UserExpireJob> implements IUserExpireJobService {

    @Resource
    private UserExpireJobMapper userExpireJobMapper;

    @Override
    public int insertBatch(List<UserExpireJob> userExpireJobs) {
        if(CollectionUtils.isNotEmpty(userExpireJobs)){
            return userExpireJobMapper.insertBatch(userExpireJobs);
        }
        return 0;
    }

    @Override
    public List<UserExpireJob> selectByUserId(Long userId) {
        return userExpireJobMapper.selectList(
                new LambdaQueryWrapper<UserExpireJob>()
                        .eq(UserExpireJob::getUserId,userId));
    }

    @Override
    public int deleteByUserId(Long userId) {
        return userExpireJobMapper.delete(
                new LambdaQueryWrapper<UserExpireJob>()
                        .eq(UserExpireJob::getUserId,userId));
    }
}
